class Solution(object):
    def largestNumber(self, nums):
        """
        :type nums: List[int]
        :rtype: str
        """
        nums = [str(num) for num in nums]
        count_0 = 0
        for num in nums:
            if num == '0':
                count_0 += 1
        if count_0 == len(nums):
            return '0'
        def judge(s1, s2):
            if s1 + s2 >= s2 + s1:
                return True
            else:
                return False

        def search(num_list):
            if len(num_list) == 1:
                return num_list
            else:
                mid_index = len(num_list) // 2
                left_list = search(num_list[: mid_index])
                right_list = search(num_list[mid_index:])
                return_list = []
                left_index = 0
                right_index = 0
                while left_index < len(left_list) and right_index < len(right_list):
                    if judge(left_list[left_index], right_list[right_index]):
                        return_list.append(left_list[left_index])
                        left_index += 1
                    else:
                        return_list.append(right_list[right_index])
                        right_index += 1
                while left_index < len(left_list):
                    return_list.append(left_list[left_index])
                    left_index += 1
                while right_index < len(right_list):
                    return_list.append(right_list[right_index])
                    right_index += 1
                return return_list

        return_list = search(nums)
        s = ''.join(return_list)
        return s


data = Solution()
nums = [10,2]
print(data.largestNumber(nums))
nums = [0, 0]
print(data.largestNumber(nums))